<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title>Facelet Title</title>
         <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            <h:form >
                 <script type="text/javascript">
                    function focusState(xhr, status, args) {  
                       if(args.validationFailed || !args.success) {}
                       else document.getElementById(tofocus).focus();
                       return false;
                   }
                    
                </script>
                 <p:outputPanel autoUpdate="true">
                <p:toolbar >
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnPrint}" icon="ui-icon-document" action="#{savReportBean.executeReport()}"
                                       ajax="false"    />                         
                        
                    </p:toolbarGroup>
                </p:toolbar>
                </p:outputPanel>
                <h:panelGrid  style="vertical-align: top" id="displaySavreport" styleClass="addELIT" cellpadding="0" columns="2" columnClasses="panelGridId,panelGridId">
                    <p:panel header="Jenis Laporan" style="margin: 0 0 0 0;">
                    
                        <p:dataTable var="rpt" value="#{savReportBean.availableMenu}" selection="#{savReportBean.selectedReport}" selectionMode="single"
                                     rowKey="#{rpt.menuId}">
			<p:ajax event="rowSelect" 
                           update=":#{utilityBean.findClientId('pnlReportFilterSaving')}" />  
                             <p:column style="width:auto" rendered="false" >
                                <f:facet name="header">ID</f:facet>
                                <h:outputText value="#{rpt.menuId}" />
                            </p:column>
                            <p:column style="width:auto" sortBy="#{rpt.menuName}">
                                <f:facet name="header">Nama Laporan</f:facet>
                                <h:outputText value="#{rpt.menuName}" />
                            </p:column>
                        </p:dataTable>
                    </p:panel>
                    
                    <p:panel header="Filter">
                        <p:panelGrid styleClass="noBorders"  id="pnlReportFilterSaving" rendered="#{savReportBean.selectedReport!=null}">
                            <p:row rendered="#{reportCfgBean.showComponent(savReportBean.selectedReport.menuId, 'TRANSDATE1;')}">
                                <p:column > <h:outputLabel value="Dari" /></p:column>                                
                                <p:column >: <p:calendar value="#{savReportBean.reportFilter.transDate1}" showOn="button" pattern="dd/MM/yyyy" size="8" /></p:column > 
                            </p:row>
                            <p:row rendered="#{reportCfgBean.showComponent(savReportBean.selectedReport.menuId, 'TRANSDATE2;')}">
                                <p:column > <h:outputLabel value="Sampai" /></p:column > 
                                <p:column >: <p:calendar value="#{savReportBean.reportFilter.transDate2}" showOn="button" pattern="dd/MM/yyyy" size="8" /></p:column>
                            </p:row>
                            <p:row rendered="#{reportCfgBean.showComponent(savReportBean.selectedReport.menuId, 'CIF;')}">
				<p:column > <h:outputLabel value="#{bundle.cif}" rendered="#{reportCfgBean.showComponent(savReportBean.selectedReport.menuId, 'CIF;')}"/></p:column > 
                                <p:column>: <p:inputText label="#{bundle.cif}" value="#{savReportBean.reportFilter.cif}" id="filCifSavReport" rendered="#{reportCfgBean.showComponent(savReportBean.selectedReport.menuId, 'CIF;')}"/>&nbsp;						 
					<p:commandButton icon="ui-icon-search" iconPos="center" styleClass="btnSmall"
                                                         update="footSavReportLookupCust"
                                            process="@this" immediate="true" action="#{savReportBean.showDialog('dlgSavReportLookupCust')}">
                                            <f:setPropertyActionListener target="#{savReportBean.showLookup}" value="#{true}" />
                                        </p:commandButton>
                                    
                                </p:column>
                            </p:row>
                            
                            <p:row rendered="#{reportCfgBean.showComponent(savReportBean.selectedReport.menuId, 'USER;')}">
                                <p:column><h:outputLabel value="#{bundle.user}" /></p:column>
                                <p:column>: <p:inputText value="#{savReportBean.reportFilter.user}" label="#{bundle.user}" /></p:column>
                            </p:row>
                            
                    </p:panelGrid>
                        </p:panel>
                </h:panelGrid>
            
            
            <!-- LOOK UP CUSTOMER -->
                <p:dialog header="#{bundle.Select} #{bundle.customer}" widgetVar="dlgSavReportLookupCust" closable="true" dynamic="true" >
                    <p:ajax listener="#{savReportBean.handleCloseLookup}" />
                    <h:panelGrid id="displaySavingReportLookup" rendered="#{savReportBean.showLookup==true}">
                    
                        <ui:include src="../master/customer/searchCustomer.xhtml" >
                            <ui:param name="lookupCustComponenId" value="savingReport" />
                        </ui:include> 

                        <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR" id="footSavReportLookupCust">
                            <f:facet name="footer">
                                
                                <p:commandButton value="#{bundle.btnOK}" icon="ui-icon-disk" immediate="true" 
                                                 process="@this" update="filCifSavReport" action="#{savReportBean.prepareCif(searchCustomer.selectedData.cif)}"
                                                oncomplete="dlgSavReportLookupCust.hide()" />
                                <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgSavReportLookupCust.hide()" immediate="true" icon="ui-icon-document" process="@this" />
                            </f:facet>
                        </h:panelGrid>
                    </h:panelGrid>    
                </p:dialog>
            
            </h:form>
        </ui:composition>
    </h:body>
</html>

